home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-17 | 5.6 KB | 196 lines | [TEXT/PJMM] |
- {}
- { File: Threads.p}
- {}
- { Contains: External Interface to Thread Manager}
- {}
- { Copyright: © 1991-1994 by Apple Computer, Inc., all rights reserved.}
- {}
- {}
- {}
-
- {$IFC UNDEFINED UsingIncludes}
- {$SETC UsingIncludes := 0}
- {$ENDC}
-
- unit Threads;
- interface
-
- { UsingThreads }
-
- { Thread Gestalt Selectors }
- const
- gestaltThreadMgrAttr = 'thds'; { Thread Manager attributes }
- gestaltThreadMgrPresent = 0; { bit true if Thread Mgr is present }
- gestaltSpecificMatchSupport = 1; { bit true if Thread Mgr supports exact match creation option }
- gestaltThreadsLibraryPresent = 2; { bit true if ThreadsLibrary (Native version) has been loaded }
-
-
- { Thread states }
- type
- ThreadState = INTEGER;
-
- const
- kReadyThreadState = 0;
- kStoppedThreadState = 1;
- kRunningThreadState = 2;
-
- { Thread environment characteristics }
- type
- ThreadTaskRef = Ptr;
-
- { Thread characteristics }
- type
- ThreadStyle = LONGINT;
-
- const
- kCooperativeThread = 1;
- kPreemptiveThread = 2;
-
- { Thread identifiers }
- type
- ThreadID = LONGINT;
-
- const
- kNoThreadID = 0;
- kCurrentThreadID = 1;
- kApplicationThreadID = 2;
-
- { Options when creating a thread }
- type
- ThreadOptions = LONGINT;
-
- const
- kNewSuspend = 1;
- kUsePremadeThread = 2;
- kCreateIfNeeded = 4;
- kFPUNotNeeded = 8;
- kExactMatchThread = 16;
-
- { Information supplied to the custom scheduler }
- type
- SchedulerInfoRecPtr = ^SchedulerInfoRec;
- SchedulerInfoRec = record
- InfoRecSize: LONGINT;
- CurrentThreadID: ThreadID;
- SuggestedThreadID: ThreadID;
- InterruptedCoopThreadID: ThreadID;
- end;
-
- { Routine proc prototypes }
- type
- { Prototype for a thread's entry routine }
- ThreadEntryProcPtr = ProcPtr; { FUNCTION ThreadMain(threadParam: LONGINT): LONGINT; }
-
- { Prototype for a custom scheduler }
- ThreadSchedulerProcPtr = ProcPtr; { FUNCTION ThreadScheduler(schedulerInfo: SchedulerInfoRec): ThreadID; }
-
- { Prototype for a custom switcher }
- ThreadSwitchProcPtr = ProcPtr; { PROCEDURE ThreadSwitcher(threadBeingSwitched: ThreadID; switchProcParam: LONGINT); }
-
- { Prototype for a custom termination notification routine}
- ThreadTerminationProcPtr = ProcPtr; { PROCEDURE ThreadTerminator(threadTerminated: ThreadID; terminationProcParam: LONGINT); }
-
- { Prototypes for debugger new, dispose & schedule thread notification }
- DebuggerNewThreadProcPtr = ProcPtr; { PROCEDURE DebuggerNewThread(threadCreated: ThreadID); }
- DebuggerDisposeThreadProcPtr = ProcPtr; { PROCEDURE DebuggerDisposeThread(threadCreated: ThreadID); }
- DebuggerThreadSchedulerProcPtr = ProcPtr; { FUNCTION DebuggerThreadScheduler(schedulerInfo: SchedulerInfoRec): ThreadID; }
-
-
- { Errors }
- const
- threadTooManyReqsErr = -617;
- threadNotFoundErr = -618;
- threadProtocolErr = -619;
-
-
- { Thread Manager routines }
- function CreateThreadPool (threadStylex: ThreadStyle; numToCreate: INTEGER; stackSize: Size): OSErr;
- inline
- $303C, $0501, $ABF2;
-
- function GetFreeThreadCount (threadStylex: ThreadStyle; var freeCount: INTEGER): OSErr;
- inline
- $303C, $0402, $ABF2;
-
- function GetSpecificFreeThreadCount ( threadStylex: ThreadStyle; stackSize: Size; VAR freeCount: INTEGER):OSErr;
- inline
- $303C, $0615, $ABF2;
-
- function GetDefaultThreadStackSize (threadStylex: ThreadStyle; var stackSize: Size): OSErr;
- inline
- $303C, $0413, $ABF2;
-
- function ThreadCurrentStackSpace (thread: ThreadID; var freeStack: LONGINT): OSErr;
- inline
- $303C, $0414, $ABF2;
-
- function NewThread (threadStylex: ThreadStyle; threadEntry: ThreadEntryProcPtr; threadParam: LONGINT; stackSize: Size; options: ThreadOptions; threadResult: LongIntPtr; var threadMade: ThreadID): OSErr;
- inline
- $303C, $0E03, $ABF2;
-
- function DisposeThread (threadToDump: ThreadID; threadResult: LONGINT; recycleThread: BOOLEAN): OSErr;
- inline
- $303C, $0504, $ABF2;
-
- function YieldToThread (suggestedThread: ThreadID): OSErr;
- inline
- $303C, $0205, $ABF2;
-
- function YieldToAnyThread: OSErr;
- inline
- $42A7, $303C, $0205, $ABF2;
-
- function GetCurrentThread (var currentThreadID: ThreadID): OSErr;
- inline
- $303C, $0206, $ABF2;
-
- function GetThreadState (threadToGet: ThreadID; var threadStatex: ThreadState): OSErr;
- inline
- $303C, $0407, $ABF2;
-
- function SetThreadState (threadToSet: ThreadID; newState: ThreadState; suggestedThread: ThreadID): OSErr;
- inline
- $303C, $0508, $ABF2;
-
- function SetThreadStateEndCritical (threadToSet: ThreadID; newState: ThreadState; suggestedThread: ThreadID): OSErr;
- inline
- $303C, $0512, $ABF2;
-
- function SetThreadScheduler (threadScheduler: ThreadSchedulerProcPtr): OSErr;
- inline
- $303C, $0209, $ABF2;
-
- function SetThreadSwitcher (thread: ThreadID; threadSwitcher: ThreadSwitchProcPtr; switchProcParam: LONGINT; inOrOut: BOOLEAN): OSErr;
- inline
- $303C, $070A, $ABF2;
-
- function SetThreadTerminator (thread: ThreadID; threadTerminator: ThreadTerminationProcPtr; terminationProcParam: LONGINT): OSErr;
- inline
- $303C, $0611, $ABF2;
-
- function ThreadBeginCritical: OSErr;
- inline
- $303C, $000B, $ABF2;
-
- function ThreadEndCritical: OSErr;
- inline
- $303C, $000C, $ABF2;
-
- function SetDebuggerNotificationProcs (notifyNewThread: DebuggerNewThreadProcPtr; notifyDisposeThread: DebuggerDisposeThreadProcPtr; notifyThreadScheduler: DebuggerThreadSchedulerProcPtr): OSErr;
- inline
- $303C, $060D, $ABF2;
-
- function GetThreadCurrentTaskRef (var threadTRef: ThreadTaskRef): OSErr;
- inline
- $303C, $020E, $ABF2;
-
- function GetThreadStateGivenTaskRef (threadTRef: ThreadTaskRef; threadToGet: ThreadID; var threadStatex: ThreadState): OSErr;
- inline
- $303C, $060F, $ABF2;
-
- function SetThreadReadyGivenTaskRef (threadTRef: ThreadTaskRef; threadToSet: ThreadID): OSErr;
- inline
- $303C, $0410, $ABF2;
-
- implementation
- end.